package com.lfy.modules.monitor;

import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lfy.domain.anno.Describe;
import com.lfy.modules.monitor.domain.ThreadPoolMonitor;
import com.lfy.modules.monitor.service.MonitorService;
import com.lfy.modules.common.utils.TimeUtils;
import lombok.extern.slf4j.Slf4j;
import org.quartz.*;


/**
 * @author 吕飞扬
 */
@Describe("清除线程池详细信息任务")
@Slf4j
@DisallowConcurrentExecution
@PersistJobDataAfterExecution
public class ThreadPoolDetailClear implements Job {
    private static final MonitorService MONITOR_SERVICE;
    static {
        MONITOR_SERVICE = SpringUtil.getBean(MonitorService.class);
    }
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        try {
            MONITOR_SERVICE.remove(new LambdaQueryWrapper<ThreadPoolMonitor>().lt(ThreadPoolMonitor::getCreateTime, TimeUtils.getFifteenDaysBefore(15)));
        } catch (Exception e) {
            log.error("清除线程池监控数据出错in package com.lfy.monitor ThreadPoolMontitor", e);
        }
    }
}
